/*
 * 退货记录表格配置
 * 定义表格列、表单字段、查询条件等
 */
export default function () {
    const table = {
        key: 'id',
        cnName: '退货记录',
        name: 'return_order',
        url: '/return_order/',
        sortName: 'create_time'
    };
    
    const tableName = table.name;
    const tableCNName = table.cnName;
    const newTabEdit = false;
    const key = table.key;
    
    const editFormFields = {
        "return_no": "",
        "order_no": "",
        "product_name": "",
        "customer_id": "",
        "create_time": "",
        "order_amount": 0,
        "Num": 0,
        "State": ""
    };
    
    const editFormOptions = [
        [
            {"title": "退货编号", "field": "return_no", "type": "text", "disabled": true},
            {"title": "订单编号", "field": "order_no", "type": "text", "disabled": true}
        ],
        [
            {"title": "商品名称", "field": "product_name", "type": "text", "disabled": true},
            {"title": "客户ID", "field": "customer_id", "type": "number", "disabled": true}
        ],
        [
            {"title": "创建时间", "field": "create_time", "type": "datetime", "disabled": true},
            {"title": "订单金额", "field": "order_amount", "type": "decimal", "disabled": true}
        ],
        [
            {"title": "数量", "field": "Num", "type": "number", "disabled": true},
            {"title": "状态", "field": "State", "type": "text", "disabled": true}
        ]
    ];
    
    const searchFormFields = {};
    const searchFormOptions = [];
    
    const columns = [
            {
                field: 'id',
                title: 'ID',
                type: 'int',
                width: 80,
                readonly: true,
                hidden: true
            },
            {
                field: 'return_no',
                title: '退货编号',
                type: 'string',
                width: 180,
                readonly: true,
                align: 'left'
            },
            {
                field: 'order_no',
                title: '订单编号',
                type: 'string',
                width: 150,
                readonly: true,
                align: 'left'
            },
            {
                field: 'product_name',
                title: '商品名称',
                type: 'string',
                width: 200,
                readonly: true
            },
            {
                field: 'customer_id',
                title: '客户ID',
                type: 'int',
                width: 100,
                readonly: true,
                align: 'center'
            },
            {
                field: 'create_time',
                title: '创建时间',
                type: 'datetime',
                width: 160,
                readonly: true,
                align: 'center'
            },
            {
                field: 'order_amount',
                title: '订单金额',
                type: 'decimal',
                width: 120,
                readonly: true,
                align: 'right',
                formatter: (row, column, cellValue) => {
                    return cellValue ? `¥${cellValue.toFixed(2)}` : '¥0.00';
                }
            },
            {
                field: 'Num',
                title: '数量',
                type: 'int',
                width: 100,
                readonly: true,
                align: 'center'
            },
            {
                field: 'State',
                title: '状态',
                type: 'string',
                width: 100,
                readonly: true,
                align: 'center'
            }
    ];
    
    const detail = {columns: []};
    const details = [];
    
    return {
        table,
        key,
        tableName,
        tableCNName,
        newTabEdit,
        editFormFields,
        editFormOptions,
        searchFormFields,
        searchFormOptions,
        columns,
        detail,
        details
    };
}

